<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@page import="edu.ccut.saturn.component.SaturnData"%>
<html>
<head>
<%@ include file="/extjs/include/all.jsp"%>
<link href="${pageContext.request.contextPath}/edu.ccut.saturn.manager.dict.impl/extpageModule/page/css/dict.css" rel="stylesheet" type="text/css">
<title>编辑用户信息</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/edu.ccut.saturn.manager.dict.impl/extpageModule/page/js/dictValidate.js">
</script>
</head>
<body>
</body>
</html>
<script>
Ext.onReady(function(){
 	Ext.QuickTips.init();  
	function getDictTypeResult(){		       	
		Ext.get("key").dom.value = '<%=request.getParameter("key")%>';
		Ext.get("keyhidden").dom.value = '<%=request.getParameter("key")%>';
		Ext.get("name").dom.value = '<%=request.getParameter("name")%>';  
    }
   
	//--------------------------------------------------------------------------------------------
	//						修改用户信息表单
	//
	//
	//
	//
	//--------------------------------------------------------------------------------------------

	var editDictType = new Ext.FormPanel({
	    labelWidth: 75,
	    id:'editDictType',
	    frame:true,
	    title: '编辑数据字典',
	    bodyStyle:'padding:5px 5px 0',
	    width: 350,
	    defaults: {width: 200},
	    defaultType: 'textfield',
		reader: new Ext.data.JsonReader({
			
		}),	
	    items: [ {	 
	            name: 'key',
	            id: 'key',
	            hidden:true,
	            inputType:'hidden'
	        },
	    
	          {
	        	fieldLabel: '数据字典',
	            name: 'keyhidden',
	            id: 'keyhidden',
	            disabled:true
	        },{
	            fieldLabel: '数据字典名称',
	            name: 'name',
	            id: 'name',
	            allowBlank:false,
	            blankText:'名称不可为空',
	            vtype: 'isNumberAlphaUnderlineChinese'
	        }
	    ]
	});
		
	//--------------------------------------------------------------------------------------------
	//						修改用户
	//
	//
	//
	//
	//--------------------------------------------------------------------------------------------
					
     var win = new Ext.Window({
         layout      : 'fit',
         width       : 400,
         height      : 200,
         plain       : true,
         animEl: 'result',
         closable: false,
         items: [editDictType],
         buttons: [{
             text     : '修改',
             handler  : function(){
                if(editDictType.form.isValid()){
                		editDictType.form.submit({					                		
                			url: '${pageContext.request.contextPath}/edu.ccut.saturn.manager.dict.impl::/extDictTypeModule/action/UpdateDictType.action', 
		               		success : function(form, action) {
		               			var myResult = Ext.util.JSON.decode(action.response.responseText);
	               				if(myResult.updateSucc == 'true'){
	               					Ext.MessageBox.show({
	               				 		title: '修改成功',
	                                    msg: '恭喜您，修改信息成功！',
	                                    width:200,
	                                    buttons: Ext.MessageBox.OK,
	                                    fn: function(btn) {
									         window.location = '${pageContext.request.contextPath}/edu.ccut.saturn.manager.dict.impl/extpageModule/page/dictTypeList.jsp';
									    }
	                                 });
								  } else {
									  	Ext.MessageBox.show({
		                                    title: '修改失败',
		                                    msg: '对不起，修改失败！可能与数据库连接发生了错误！',
		                                    buttons: Ext.MessageBox.OK,
		                                    icon: Ext.MessageBox.ERROR
	                                	});
								  }
		                    },
                      	    failure: function(form, action) {
		                       	Ext.MessageBox.show({
		                                   title: '修改失败',
		                                   msg: '对不起，修改信息失败！',
		                                   buttons: Ext.MessageBox.OK,
		                                   icon: Ext.MessageBox.ERROR
			                                	});
	                        },
              				waitMsg:'正在修改信息，请稍后...'
               			});
                	}else{
                		Ext.MessageBox.alert('警告','对不起，您的信息有误！')
                	}
                }
            },{
                text     : '返回',
                handler  : function(){
                    window.location='${pageContext.request.contextPath}/edu.ccut.saturn.manager.dict.impl/extpageModule/page/dictTypeList.jsp';
                    }
           },{
                text     : '重置',
                handler  : function(){
                    getDictTypeResult();
                }
            }]
       });
       win.show();
        getDictTypeResult();
});

</script>
